Skip to content

[FEATURE] add extrapolate, IIR extrapolation of a spectrum beyond its range - #121

Open
aguirreSL wants to merge 2 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-extrapolate
Open

aguirreSL wants to merge 2 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-extrapolate

Conversation

@aguirreSL

Copy link
Copy Markdown

Adds extrapolate(signal, freqRange, order=4) to pytta.functions, the extrapolation of a spectrum beyond its valid range of ita_extrapolate of the ITA-Toolbox. Outside freqRange = [f1, f2] the spectrum is replaced by IIR models fitted near each end with invfreqz (#110). The low model is fitted on f1 + (0.01 to 0.2)(f2 - f1) and used below f1, and the high model on f1 + (0.9 to 0.99)(f2 - f1) and used above f2, the bands of the ITA-Toolbox.

The ITA-Toolbox fits with MATLAB's rationalfit (RF Toolbox), which has no SciPy counterpart; the equation error fit of invfreqz takes its place. A pure delay is not a low-order model, so it should be removed first (time_shift of #96); the ITA-Toolbox removes it inside the function. The ITA code was read for its semantics only and nothing was copied.

This pull request builds on #110 and shows its commit until #110 is merged.

The test in tests/test_extrapolate.py takes a band-pass filter of order 4, replaces its spectrum outside 300 Hz to 3 kHz by noise, and extrapolates with models of order 4: the spectrum comes back outside that range within 3.2e-4 of its peak, which is what the float32 samples of SignalObj allow.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

aguirreSL and others added 2 commits November 1, 2026 01:47
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… range

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant